package cn.demo.text.editor.config;

import cn.demo.text.editor.constant.Str;
import cn.demo.text.editor.strategy.format.process.FormatFactory;
import cn.demo.text.editor.strategy.format.process.PriFormat;
import cn.demo.text.editor.strategy.menu.action.*;

import javax.swing.*;

public class InitClass {

    public static void initStrategy() {
        ActionFactory.context.put(Str.EXIT, new ExitAction());
        ActionFactory.context.put(Str.OPEN, new OpenAction());
        ActionFactory.context.put(Str.PASSWORD, new PasswordAction());
        ActionFactory.context.put(Str.SAVE, new SaveAction());
        ActionFactory.context.put(Str.SAVE_AS, new SaveAsAction());
        ActionFactory.context.put(Str.SEARCH, new SearchAction());

        FormatFactory.context.put(Str.PRI_FILE_SUFFIX, new PriFormat());
    }

    public static void initLookAndFeel() {
        String lookAndFeel = UIManager.getSystemLookAndFeelClassName();
        try {
            UIManager.setLookAndFeel(lookAndFeel);
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                | UnsupportedLookAndFeelException e) {
            e.printStackTrace();
        }
    }

}
